#pragma once
#include <jmutex.h>

class MutexBuffer
{
public:
	MutexBuffer(const size_t& size);
	size_t Write( const void* data, const size_t& size );
	size_t Read( void* buf, const size_t& size );
	size_t GetSize();
	~MutexBuffer();
private:
	size_t WriteRecursive( const void* data, const size_t& size );
	size_t ReadRecursive( void* buf, const size_t& size );
private:
	void* buf;
	size_t bufSize;
	int head, tail;
	JMutex mutex;
	bool nothingToRead, nowhereToWrite;
};
